package com.gaotu.demo.jvm;

import lombok.Getter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("jit")
@RestController
public class JITController {
    private int base = 10;

    @GetMapping("test")
    public int test(){
        int sum = 0;
        for (int i=0;i<1000000;i++){
            sum = getSum(sum);
        }
        return sum;
    }

    private int getSum(int count){
        Object lock = new Object();
        synchronized (lock) {
            return getBase() + count;
        }
    }

    public int getBase(){
        return this.base;
    }


    public static void main(String... args){
        new JITController().test();
    }
}
